import pygame, sys, math

from Player import *

class HB(pygame.sprite.Sprite):
    def __init__(self, owner, pos = (250, 250), path = "rsc/Health Bar/"):
        pygame.sprite.Sprite.__init__(self, self.containers)
        self.path = path
        self.owner = owner
        life = int(math.ceil(self.owner.health/10.0)*10)
        self.image = pygame.image.load("rsc/Health Bar/10.png")
        self.rect = self.image.get_rect()
        self.place(pos)
        
        
    def place(self, pos):
        self.rect.center = pos
        
        
    def update(*args):
        self = args[0]
        life = int(math.ceil(self.owner.health/10.0)*10)
        if life <= 0:
            life = 0
        elif life >= 100:
            life = 100
        self.image = pygame.image.load(self.path + str(life) + ".png")
        #self.rect = self.image.get_rect()
        
        

        


